import { reactive } from "vue";
import FormCenter from "./form-center";
import DataCenter from "./data-center";
import RegisterCenter from "./register-center";
import EventCenter from "./event-center";
export const useCenter = () => {
  const centerMap = reactive({});
  const initCenter = (formId, formRef) => {
    const formCenterInstance = new FormCenter(formId, formRef);
    const dataCenterInstance = new DataCenter(formId);
    const registerCenterInstance = new RegisterCenter(formId);
    const eventCenterInstance = new EventCenter(formId);
    const connector = {
      formCenterInstance,
      dataCenterInstance,
      registerCenterInstance,
      eventCenterInstance,
    };
    formCenterInstance.setConnector(connector);
    dataCenterInstance.setConnector(connector);
    registerCenterInstance.setConnector(connector);
    eventCenterInstance.setConnector(connector);
    Object.assign(centerMap, connector);
  };

  return {
    initCenter,
    centerMap,
  };
};
